package tcu.iot.gasmanage.common.utils;

import tcu.iot.gasmanage.common.Result;
import tcu.iot.gasmanage.entity.datamanagement.UpdateRealTimeData;
import tcu.iot.gasmanage.entity.datatable.SeriesReturn;
import tcu.iot.gasmanage.entity.equipment.EquipmentInfoResult;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class EquipmentInfoResultUtils {

    public static Result EquipmentInfoDataResult(List<EquipmentInfoResult> list) {
        List<Object> i1List = new ArrayList<>();
        List<Object> i2List = new ArrayList<>();
        List<Object> i3List = new ArrayList<>();
        List<Object> i4List = new ArrayList<>();

        for (EquipmentInfoResult equipmentInfoResult : list) {
            String Time = DateUtils.localToUTC(equipmentInfoResult.getTime());

            List<Object> i1 = new ArrayList<>();
            i1.add(Time);
            i1.add(equipmentInfoResult.getI1());
            i1List.add(i1);

            List<Object> i2 = new ArrayList<>();
            i2.add(Time);
            i2.add(equipmentInfoResult.getI2());
            i2List.add(i2);

            List<Object> i3 = new ArrayList<>();
            i3.add(Time);
            i3.add(equipmentInfoResult.getI3());
            i3List.add(i3);

            List<Object> i4 = new ArrayList<>();
            i4.add(Time);
            i4.add(equipmentInfoResult.getI4());
            i4List.add(i4);
        }

        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("i1data", i1List);
        hashMap.put("i2data", i2List);
        hashMap.put("i3data", i3List);
        hashMap.put("i4data", i4List);

        return Result.ok("true", 200, "成功", hashMap);
    }

    //DataManagementService
    public static List<List<Object>> UpdateRealTimeResult(List<UpdateRealTimeData> list, String dataType) {
        List<List<Object>> dataList = new ArrayList<>();

        for (UpdateRealTimeData updateRealTimeData : list) {
            String Time = DateUtils.localToUTC(updateRealTimeData.getTime());

            List<Object> data = new ArrayList<>();
            data.add(Time);
            data.add(updateRealTimeData.getData());
            dataList.add(data);
        }

        return dataList;
    }
}
